﻿using System;
using System.Collections.Generic;
using System.Text;

namespace SimpleFactory
{
  
    public abstract class DeviceBase
    {
        public string DeviceName { get; private set; }
      
        public DeviceBase(string deviceName)
        {
            this.DeviceName = deviceName;
        }

        public virtual void TransData()
        {
            Console.WriteLine(this.DeviceName + "开始拷贝数据");
        }
    }

    public class Factory
    {

        public static DeviceBase CreateDevice(DeviceType deviceType)
        {
            DeviceBase device = null;
            switch (deviceType)
            {
                case DeviceType.Mp3:
                    device = new Mp3Device("老古董Mp3");
                    break;
                case DeviceType.Phone:
                    device = new PhoneDevice("电气年代电话");
                    break;
                case DeviceType.Camera:
                    device = new CameraDevice("现代照相机");
                    break;
                default:
                    break;
            }
            return device;
        }
    }


    #region devices

    public class Mp3Device : DeviceBase
    {
        public Mp3Device(string deviceName) : base(deviceName)
        {
        }
    }

    public class PhoneDevice : DeviceBase
    {
        public PhoneDevice(string deviceName) : base(deviceName)
        {
        }
    }

    public class CameraDevice : DeviceBase
    {
        public CameraDevice(string deviceName) : base(deviceName)
        {
        }
    }

    #endregion

    public enum DeviceType
    {
        Mp3,
        Phone,
        Camera,
    }
}
